

// import 'package:board_datetime_picker/board_datetime_picker.dart';
import 'package:flutter/material.dart';
import 'package:flutter_datetime_picker_plus/flutter_datetime_picker_plus.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:gczn_hd/app/core/base/handle_mixin.dart';
import 'package:gczn_hd/app/core/values/App_img.dart';
import 'package:gczn_hd/app/core/values/app_colors.dart';
import 'package:gczn_hd/app/core/values/app_values.dart';
import 'package:gczn_hd/app/core/values/text_styles.dart';
import 'package:gczn_hd/app/core/widget/custom_title_bar.dart';
import 'package:gczn_hd/app/core/widget/gc_date_time.dart';
import 'package:gczn_hd/app/modules/ppm/create_report/controllers/create_report_controller.dart';
import 'package:get/get.dart';

class FormLeft extends StatelessWidget with HandleMixin{

  final CreateReportController controller = Get.put(CreateReportController());

  final double inputHeight = 60.0;

  @override
  Widget build(BuildContext context) {

    return Column(
      children: [
        const CustomTitleBar(title: "扇叶注塑-工位A09"),
        _buildArticlesBeing(),
        _buildOutput(),
        _buildForm(context)
      ],
    );

  }

  /// 表单
  Widget _buildForm(BuildContext context){

    return Obx(() => Container(
      margin: EdgeInsets.only(top: AppValues.size36.h),
      child: Column(
        crossAxisAlignment: CrossAxisAlignment.start,
        children: [
          _buildFormBc(), // 班次
          SizedBox(height: AppValues.size36.h,),
          _buildFormPerson(), // 作业人员
          SizedBox(height: AppValues.size36.h,),
          _buildFormStartTime(context),
          SizedBox(height: AppValues.size36.h,),
          _buildFormEndTime(),

        ],
      ),
    ));
  }

  Widget _buildFormEndTime(){

    return Row(
      children: [
        SizedBox(
          width: AppValues.size108.w,
          child: Text("作业结束", style: textStyle20Opa8,),
        ),
        Expanded(
          flex: 1,
          child: Container(
            height: inputHeight.h,
            padding: EdgeInsets.only(left: AppValues.iconSize_14.w, right: AppValues.iconSize_14.w),
            decoration: BoxDecoration(
              border: Border.all(
                color: AppColors.tableBorder,
                width: 1.0,
              ),
              borderRadius: BorderRadius.circular(AppValues.margin_12.r),
              color: Colors.transparent,
            ),
            child: Row(
              children: [
                Expanded(
                  child: Text("2025-1-5 19:00:00", style: textStyle,),
                ),
                _buildIconArrow()
              ],
            ),
          ),
        )
      ],
    );
  }

  Widget _buildFormStartTime(BuildContext context){

    return Row(
      children: [
        SizedBox(
          width: AppValues.size108.w,
          child: Text("作业开始", style: textStyle20Opa8,),
        ),
        Expanded(
          flex: 1,
          child: GestureDetector(
            onTap: () async {
              // final result = await showBoardDateTimePicker(
              //   context: context,
              //   pickerType: DateTimePickerType.datetime,
              // );
              // DatePicker.showDateTimePicker(context, locale: LocaleType.zh);  // 可用
              // await showDatePicker(context: context, firstDate: DateTime(1900), lastDate: DateTime(2050));
              // await showTimePicker(context: context, initialTime: TimeOfDay.now());
              // Get.dialog(AlertDialog(
              //     backgroundColor: AppColors.gcznPrimaryColorBg,
              //     content: GcDateTime( call: (DateTime time){
              //       print('time=${time}');
              //     })
              // ));
            },
            child: Container(
              height: inputHeight.h,
              padding: EdgeInsets.only(left: AppValues.iconSize_14.w, right: AppValues.iconSize_14.w),
              decoration: BoxDecoration(
                border: Border.all(
                  color: AppColors.tableBorder,
                  width: 1.0,
                ),
                borderRadius: BorderRadius.circular(AppValues.margin_12.r),
                color: Colors.transparent,
              ),
              child: Row(
                children: [
                  Expanded(
                    child: Text("2025-1-5 08:00:00", style: textStyle,),
                  ),
                  _buildIconArrow()
                ],
              ),
            ),
          ),
        )
      ],
    );
  }
  

  /// 作业人员
  Widget _buildFormPerson(){
    return Row(
      children: [
        SizedBox(
          width: AppValues.size108.w,
          child: Text("作业人员", style: textStyle20Opa8,),
        ),
        Expanded(
          flex: 1,
          child: Container(
            height: inputHeight.h,
            padding: EdgeInsets.only(left: AppValues.iconSize_14.w, right: AppValues.iconSize_14.w),
            decoration: BoxDecoration(
              border: Border.all(
                color: AppColors.tableBorder,
                width: 1.0,
              ),
              borderRadius: BorderRadius.circular(AppValues.margin_12.r),
              color: Colors.transparent,
            ),
            child: Row(
              children: [
                Expanded(
                  child: Text("冠生;Thq", style: textStyle,),
                ),
                _buildIconArrow()
              ],
            ),
          ),
        )
      ],
    );
  }
  

  /// 班次
  Widget _buildFormBc(){
    return Row(
      children: [
        SizedBox(
          width: AppValues.size108.w,
          child: Text("作业班次", style: textStyle20Opa8,),
        ),
        Expanded(
          flex: 1,
          child: Container(
            height: inputHeight.h,
            padding: EdgeInsets.only(left: AppValues.iconSize_14.w, right: AppValues.iconSize_14.w),
            decoration: BoxDecoration(
              border: Border.all(
                color: AppColors.tableBorder,
                width: 1.0,
              ),
              borderRadius: BorderRadius.circular(AppValues.margin_12.r),
              color: Colors.transparent,
            ),
            child: Row(
              children: [
                Expanded(
                  child: DropdownButton(
                    value: controller.bcSelect.value,
                    padding: EdgeInsets.zero,
                    underline: Container(height: 0,),
                    iconSize: 0,
                    style:  submitButtonText.copyWith(fontSize: AppValues.size24.sp),
                    items: controller.bcList.map<DropdownMenuItem<String>>((String value) {
                      return DropdownMenuItem<String>(
                        value: value,
                        child: Text(value),
                      );
                    }).toList(),
                    onChanged: (String? newValue){
                      controller.bcSelect.value = newValue!;
                    },
                    dropdownColor: AppColors.gcznPrimaryBlueBg,
                  ),
                ),
                _buildIconArrow()
              ],
            ),
          ),
        )
      ],
    );
  }


  Widget _buildIconArrow(){
    return Icon(Icons.arrow_forward_ios_outlined, color: AppColors.colorWhite, size: AppValues.size20.w,);
  }

  
  
  /// 产量
  Widget _buildOutput(){
    
    return Row(
      crossAxisAlignment: CrossAxisAlignment.center,
      mainAxisAlignment: MainAxisAlignment.spaceBetween,
      children: [
        Column(
          children: [
            Text("计划产量", style: textStyle20Opa8,),
            Text("1000", style: textStyle30Bold,)
          ],
        ),
        Column(
          children: [
            Text("计划产量", style: textStyle20Opa8,),
            Text("1000", style: textStyle30Bold,)
          ],
        ),
        Column(
          children: [
            Text("计划产量", style: textStyle20Opa8,),
            Text("1000", style: textStyle30Bold,)
          ],
        )
      ],
    );
  }


  /// 在制品
  Widget _buildArticlesBeing(){

    return Container(
      margin: EdgeInsets.only(top: AppValues.size52.h, bottom:  AppValues.size36.h),
      child: Row(
        children: [
          SizedBox(
            child: Image.asset(AppImg.goodspic, width: AppValues.size60.w, height: AppValues.size60.w,),
          ),
          SizedBox(width: AppValues.iconSize_18.w,),
          Expanded(
            flex: 1,
            child: Text("格力空气循环落地风扇", style: textStyle30, maxLines: 2, overflow: TextOverflow.ellipsis,),
          )
        ],
      ),
    );
  }

}